// pages/order/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabs: [
      {
        id: 0,
        value: "全部",
        isActive: true
      },
      {
        id: 1,
        value: "待付款",
        isActive: false
      },
      {
        id: 2,
        value: "待发货",
        isActive: false
      },
      {
        id: 3,
        value: "退款/退货",
        isActive: false
      }
    ]
  },

  onShow: function () {
    // 获取参数 type 
    let pages = getCurrentPages();
    // console.log(pages);
    const { type } = pages[pages.length - 1].options
    // console.log(type);
    this.currentTabs(type - 1)
  },

  // tab 栏切换
  handleTapChange (e) {
    // console.log(e);
    const { index } = e.detail
    this.currentTabs(index)
  },

  // 
  currentTabs (index) {
    let { tabs } = this.data
    tabs.forEach(v => v.id === index ? v.isActive = true : v.isActive = false)
    this.setData({
      tabs
    })
  }

})